package st.business.tepth.business.maintainplan;

import java.util.List;

import st.business.tepth.base.OnDataConvertListener;
import st.business.tepth.business.bean.MaintainPlanBean;

/**
 * Author: shadow
 * Email:  1025431817@qq.com
 * Time:   2019-06-04 16:04
 */

public class MaintainPlanPresenter extends MaintainPlanContract.Presenter {
    private final MaintainPlanContract.View mView;
    private final MaintainPlanContract.Model mModel;

    public MaintainPlanPresenter(MaintainPlanContract.View view) {
        mView = view;
        mModel = new MaintainPlanModel();
    }

    @Override
    void getMaintainPlanList(String token, String date) {
        addDisposable(mModel.getMaintainPlanList(token,date,
                new OnDataConvertListener<List<MaintainPlanBean>>() {
                    @Override
                    public void convert(List<MaintainPlanBean> list) {
                        if (mView != null) {
                            mView.showMaintainPlanList(list);
                        }
                    }

                    @Override
                    public void error(int code, String msg) {
                        if (mView != null) {
                            mView.showMaintainPlanList(null);
                        }
                    }
                }));
    }
}
